package com.uestc.qiniu;

import com.qiniu.common.QiniuException;
import com.qiniu.storage.BucketManager;
import com.qiniu.storage.model.FileInfo;
import com.qiniu.storage.model.FileListing;
import com.qiniu.util.Auth;

public class QNManager {

	private Auth managerAuth = GenToken.getAuth();
	private BucketManager bucketManager = new BucketManager(managerAuth);
	FileInfo[] items;
	FileListing fileListing;
	String marker;

	/**
	 * 返回信息, 只能往下找，不能向前找
	 * 
	 * @param marker
	 * @param limit
	 * @throws QiniuException
	 */
	public FileInfo[] getFilesInfo(int limit, String marker) throws QiniuException {
		fileListing = bucketManager.listFiles(QNConfig.BUCKET, null, marker, limit, null);
		items = fileListing.items;
		this.marker = fileListing.marker;
		return items;
	}

	public String getMarker() {
		return marker;
	}
	
	public static void main(String[] args) {
		QNManager qnManager = new QNManager();
		try {
			qnManager.getFilesInfo(20, null);
		} catch (QiniuException e) {
			e.printStackTrace();
		}
	}
}
